package service

import (
	"fmt"
	Mysql "gin/database"
	"github.com/spf13/viper"
)

// 获得表字段
func GetTableFields(tableName string) []string {

	var res []string
	if tableName == "" {
		return res
	}

	Mysql.DB.Raw(fmt.Sprintf("SELECT COLUMN_NAME FROM information_schema.`COLUMNS` WHERE  TABLE_SCHEMA='%s' AND TABLE_NAME = '%s' ", viper.GetString("mysql.database"), tableName)).Scan(&res)
	return res

}
